package com.ruoyi.law.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.law.domain.ContentCaseStep;
import com.ruoyi.law.service.IContentCaseStepService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流程步骤Controller
 *
 * @author gyl
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/contentCaseStep/contentCaseStep")
public class ContentCaseStepController extends BaseController
{
    @Autowired
    private IContentCaseStepService contentCaseStepService;

    /**
     * 查询流程步骤列表
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContentCaseStep contentCaseStep)
    {
        startPage();
        List<ContentCaseStep> list = contentCaseStepService.selectContentCaseStepList(contentCaseStep);
        return getDataTable(list);
    }

    /**
     * 导出流程步骤列表
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:export')")
    @Log(title = "流程步骤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContentCaseStep contentCaseStep)
    {
        List<ContentCaseStep> list = contentCaseStepService.selectContentCaseStepList(contentCaseStep);
        ExcelUtil<ContentCaseStep> util = new ExcelUtil<ContentCaseStep>(ContentCaseStep.class);
        util.exportExcel(response, list, "流程步骤数据");
    }

    /**
     * 获取流程步骤详细信息
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:query')")
    @GetMapping(value = "/{stepId}")
    public AjaxResult getInfo(@PathVariable("stepId") Long stepId)
    {
        return success(contentCaseStepService.selectContentCaseStepByStepId(stepId));
    }

    /**
     * 新增流程步骤
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:add')")
    @Log(title = "流程步骤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContentCaseStep contentCaseStep)
    {
        contentCaseStep.setCreateBy(getUsername());
        return toAjax(contentCaseStepService.insertContentCaseStep(contentCaseStep));
    }

    /**
     * 修改流程步骤
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:edit')")
    @Log(title = "流程步骤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContentCaseStep contentCaseStep)
    {
        contentCaseStep.setUpdateBy(getUsername());
        return toAjax(contentCaseStepService.updateContentCaseStep(contentCaseStep));
    }

    /**
     * 删除流程步骤
     */
    @PreAuthorize("@ss.hasPermi('contentCaseStep:contentCaseStep:remove')")
    @Log(title = "流程步骤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stepIds}")
    public AjaxResult remove(@PathVariable Long[] stepIds)
    {
        return toAjax(contentCaseStepService.deleteContentCaseStepByStepIds(stepIds));
    }
}
